package service.impl;
 import dao.UserDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import pojo.User;
 import service.UserService;
 
 import java.util.List;
 @Service("userService")
 public class UserServiceImpl implements UserService {
     @Autowired
     private UserDao userDao;


     @Override
     public int addUser(User user) {
         return userDao.addUser(user);
     }

     @Override
     public User findUserById(int id) {
         return userDao.findUserById(id);
     }

     @Override
     public int updateUser(User user) {
         return userDao.updateUser(user);
     }

     @Override
     public int deleteUserById(Integer id) {
         return userDao.deleteUserById(id);
     }

     @Override
     public List<User> findAll(User user, int offser, int pageSize) {
         List<User> users = userDao.findAll(user, offser, pageSize);
         return users;

     }

     @Override
     public int count(User user) {
         return userDao.count(user);
     }

     @Override
     public boolean login(User user) {
         int count = userDao.login(user);
         if (count > 0) {
             return true;
         }else{
             return false;
         }

     }

     @Override
     public int findUserByName(String name) {
         return userDao.findUserByName(name);
     }
 }
